<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .big {
            width: 500px;
            height: 900px;
            /* background-color: #ccc; */
            display: flex;
            justify-content: space-around;
            flex-wrap: wrap;
            padding-top: 50px;
            position: relative;
        }
        .text{
            position: absolute;
            top: -20px;
        }
        img{
            width: 150px;
            height: 150px;
        }
        .one,.two,.three,.four,.five,.six,.seven,.eight{
            width: 200px;
            height: 200px;
            box-shadow: 2px 2px 10px #000;
            text-align: center;
            cursor: pointer;
            border-radius: 10px;
        }
    </style>
</head>
<body>
    <div id="app">
        
        <parent></parent>
    </div>
    <script src="./js/vue.js"></script>
    <script>
        let app = new Vue({
            el: "#app",
            data() {
                return {}
            },
            components: {
                parent: {
                    template: `
                    <div class="big">
                        <h2 class="text">点击：</h2>
                        <one></one>
                        <two></two>
                        <three></three>
                        <four></four>    
                        <five></five>
                        <six></six>
                        <seven></seven>    
                        <eight></eight>
                    </div>
                    `,
                    components: {
                        one: {
                            template: `
                            <div class="one" @click="show">
                                <img src="./img/1.jpeg" alt="">
                                <h5>图片一</h5>  
                            </div>
                            `,
                            methods:{
                                show(){
                                    this.$emit('show')
                                }
                            }
                        },
                        two: {
                            template: `
                        <div class="two">
                            <img src="./img/2.jpeg" alt="">
                            <h5>图片二</h5>  
                        </div>
                        `
                        },
                        three: {
                            template: `
                        <div class="three">
                            <img src="./img/3.jpeg" alt="">
                            <h5>图片三</h5>  
                        </div>
                        `
                        },
                        four: {
                            template: `
                        <div class="four">
                            <img src="./img/4.jpeg" alt="">
                            <h5>图片四</h5>  
                        </div>
                        `
                        },
                        five: {
                            template: `
                        <div class="five">
                            <img src="./img/5.jpeg" alt="">
                            <h5>图片五</h5>  
                        </div>
                        `
                        },
                        six: {
                            template: `
                        <div class="six">
                            <img src="./img/6.jpeg" alt="">
                            <h5>图片六</h5>  
                        </div>
                        `
                        },
                        seven: {
                            template: `
                        <div class="seven">
                            <img src="./img/7.jpeg" alt="">
                            <h5>图片七</h5>  
                        </div>
                        `
                        },
                        eight: {
                            template: `
                        <div class="eight">
                            <img src="./img/8.jpeg" alt="">
                            <h5>图片八</h5>  
                        </div>
                        `
                        },
                    }
                },
            }
        })
        Vue.component("parent", parent);
    </script>
</body>
</html>